import axios from 'axios'

const server = axios.create({
    baseUrl: '',
    timeout: 5000
})

server.interceptors.request.use(config =>{ 
    if(localStorage.getItem('token')) {
        config.headers.token = localStorage.getItem('token')
    }
    return config
}, err => {
    return Promise.reject(err)
})

server.interceptors.response.use(res => {
    if(res.data == "token无效") {
        console.log('请重新登录')
    }
    return res.data
}, err => {
    return Promise.reject(res)
})

export default server